home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pcv05n09.zip / GRPLAN.WBT < prev    next >
Text File  |  1993-06-13  |  5KB  |  129 lines

  1. ;; by Heather Stern
  2. ;; with help from Robin Selder, Mark Lawler, and Tod DeBie  5/29/92
  3.  
  4. ;;;;; RunGroup - A Batch Runner Program by Heather Stern
  5. ;;; purpose: run all the items of a user-chosen group.
  6. ;;; method: use DDE conversation with the Program Manager or Norton Desktop
  7.  
  8. m="This is a batch file that will run all of the items in a user selected group."
  9. Message ("NDW Group Runner",m)
  10. Drop(m)
  11.  
  12. :DDEinit
  13. channel = DDEInitiate("Progman","Progman")    ; begin conversation
  14. section ="group list"                ; okay to terminate DDE if 
  15.                         ; user cancels
  16.   ; loop at this location until user enters a valid group or Cancels
  17. :DDEtop
  18. xx=DDERequest(channel,"PROGMAN")
  19. xx=StrReplace(xx,Num2Char(13),",")
  20. xx=StrReplace(xx,Num2Char(10),"")
  21. group = ItemSelect("Select Group",xx,",")
  22.  
  23. ;;; if user entered valid group, this will return data about it
  24. ;;; if invalid, NACK will be in the return string
  25. items = DDERequest (channel, group)
  26. nack = StrIndex(items, "NACK", 0, @FWDSCAN)
  27. if nack <> 0 then goto error
  28.   ; terminate conversation now that we have recieved our data
  29. DDETerminate(channel)
  30.  
  31. section ="retrieve group data"
  32. ;;; Retrieve the number of objects from the first line.
  33.   ; split the data into the first line and the rest of it.
  34. endLine1 = StrIndex (items, Num2Char(13), 0, @FWDSCAN)
  35.  
  36. ;;; trap for no CRs
  37. if endLine1 == 0 then goto empty
  38.  
  39. ;;; we have a CR, split at that
  40. Line1 = StrSub (items, 1, endLine1 - 1)
  41. Items = StrSub (items, endLine1 + 1, StrLen(items) - endLine1)
  42.   ; now we use the first line and retrieve the number
  43.   ; peel off last number and its comma
  44. endLine1 = StrIndex (Line1, ",", StrLen(Line1), @BACKSCAN)
  45. Line1 = StrSub (Line1, 1, endLine1 - 1)
  46.   ; our result is next. Starting from its comma, to end of first line
  47. endLine1 = StrIndex (Line1, ",", StrLen(Line1), @BACKSCAN)
  48. numItems = StrSub (Line1, endLine1 + 1, StrLen(Line1) - endLine1)
  49.  
  50. ;;; spot an empty group
  51. if numItems == 0 then goto empty
  52.  
  53. ;;; now that we know how many objects, retrieve commandline for each object
  54. :ItemTop
  55. if numItems == 0 then goto ItemBottom
  56.   ; split the data into the first line and the rest of it.
  57. endLine1 = StrIndex (items, Num2Char(13), 0, @FWDSCAN)
  58. Line1 = StrSub (items, 1, endLine1 - 1)
  59. Items = StrSub (items, endLine1 + 1, StrLen(items) - endLine1)
  60.   ; our commandline is the second item. peel away the first.
  61. cmdAt = StrIndex (Line1, ",", 0, @FWDSCAN)
  62. Line1 = StrSub (Line1, cmdAt + 1, StrLen(Line1) - cmdAt)
  63. cmdAt = StrIndex (Line1, ",", 0, @FWDSCAN)
  64. cmdLine = StrSub (Line1, 1, cmdAt - 1)
  65.   ; prune the quote marks
  66. cmdLine = StrSub (Line1, 2, StrLen(cmdLine) - 2)
  67. drop (cmdAt, Line1)
  68.   ; let a subsection handle whether there are parameters for this program.
  69. goto runItem
  70. :ranItem
  71.   ; done with this item, on to the next.
  72. numItems = numItems - 1
  73. goto ItemTop
  74.   
  75. :itemBottom
  76. ;;; we are now done!
  77. Display (10, "Group Runner","All tasks are running now!")
  78. Exit
  79.  
  80. :runItem
  81. ;;; seperated section - parse string from cmdLine area into 2 parameters for Run
  82. if StrLen(cmdLine) == 0 then goto ranItem       ; there was nothing to run
  83. spaceAt = StrIndex (cmdLine, " ", 0, @FWDSCAN)
  84. if spaceAt == 0 then goto noParms
  85. Program = StrSub (cmdLine, 1, spaceAt - 1)
  86. Parms   = StrSub (cmdLine, spaceAt + 1, StrLen(cmdLine) - spaceAt)
  87. drop (spaceAt, cmdLine)
  88.    ; trap for invalid icon
  89. if FileExist (Program) == @FALSE then goto noRun
  90. Run (Program, Parms)
  91.    ; if your task is slow to load a delaying action might be placed here.
  92. Drop (Program, Parms)
  93. goto ranItem
  94.  
  95. :noParms
  96. drop (spaceAt)
  97.    ; trap for invalid icon
  98. if FileExist (cmdLine) == @FALSE then goto noRun
  99. Run (cmdLine, "")
  100.    ; if your task is slow to load a delaying action might be placed here.
  101. Drop (cmdLine)
  102. goto ranItem
  103.  
  104. :noRun
  105. if IsDefined (cmdLine) then msg=cmdLine
  106. if IsDefined (Program) then msg=Program
  107. msg=StrCat("Object ", msg, " no longer exists.")
  108. Display (10,"NDW Group Runner",msg)
  109. Drop (msg)
  110. goto ranItem
  111.  
  112. :error           ; user chose invalid group name
  113. Message ("Group Runner", "%group% group no longer exists")
  114. goto DDEtop        ; ask the user again
  115.  
  116. :empty
  117. a="I cannot run a group with no icons."
  118. b="Press OK to choose a new group or CANCEL to quit."
  119. msg=StrCat(a,Num2Char(13),b)
  120. Pause ("NDW Group Runner",msg)
  121. drop (a,b,msg)
  122. goto DDEinit    ; only reach here if they wish to select another
  123.         ; channel has terminated, so re-initiate
  124.  
  125.   ; Batch Runner CANCEL choices automatically branch here.
  126. :cancel
  127. if StrCmp(section,"group list") == 0 then DDETerminate (channel)
  128. Exit
  129.